package com.woniuxy.dr_mall.controller;


import com.woniuxy.dr_mall.entity.MyResponseEntity;
import com.woniuxy.dr_mall.service.IDrUserFavoriteService;
import com.woniuxy.dr_mall.utils.Audience;
import com.woniuxy.dr_mall.utils.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张哲轩
 * @since 2021-08-11
 */
@RestController
@RequestMapping("/dr_mall/drUserFavorite")
public class DrUserFavoriteController {
    @Autowired
    IDrUserFavoriteService iDrUserFavoriteService;

    @Autowired
    Audience audience;
    //通过用户id和商品id删除用户收藏的信息 2021-8-16 叶官鑫
    @GetMapping("deleteFavorite")
    public MyResponseEntity deleteFavorite(@RequestHeader("token") String token, int productId){
        int userId = JwtUtil.getId(token, audience.getBase64Secret());
        iDrUserFavoriteService.deleteFavorite(userId,productId);
        return new MyResponseEntity(200,"ok");
    }

}

